//
//  CustomNavBar.swift
//  健身宝
//
//  Created by hzt on 2017/10/30.
//  Copyright © 2017年 hzt. All rights reserved.
//

import UIKit

class CustomNavBar: UIView {
    var backBtn:UIButton!
    
    override init(frame: CGRect) {
        super.init(frame: frame)
    }
    
    func initialize(text:String?){
        backgroundColor = .white
        
        if let _text = text{
            let title = UILabel(frame: CGRect(x: 0, y: 0, width: 200, height: 20))
            title.center = CGPoint(x: center.x, y: 42)
            title.textAlignment = .center
            title.textColor = UIColor.black
            title.font = UIFont.boldSystemFont(ofSize: 20)
            title.text = _text
            title.tag = 1
            addSubview(title)
        }
        backBtn = UIButton(frame: CGRect(x: 16, y: 23, width: 35, height: 30))
        backBtn.titleLabel?.font = UIFont.systemFont(ofSize: 17)
        backBtn.setTitle("返回", for: .normal)
        backBtn.setTitleColor(.black, for: .normal)
        addSubview(backBtn)
        
        let line = CAShapeLayer()
        line.frame = CGRect(x: 0, y: bounds.height-0.5, width: UIScreen.main.bounds.width, height: 0.5)
        line.backgroundColor = UIColor.lightGray.cgColor
        layer.addSublayer(line)
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}

